package com.duing.exception;

import com.duing.common.ResponseResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public ResponseResult<Void> handleException(Exception e) {
//        log.error("系统异常：", e);
        System.out.println(e);
        return ResponseResult.error(500, "系统繁忙，请稍后再试");
    }

    @ExceptionHandler(BusinessException.class)
    public ResponseResult<Void> handleBusinessException(BusinessException e) {
//        log.warn("业务异常：{}", e.getMessage());
        return ResponseResult.error(e.getCode(), e.getMessage());
    }
}
